
export default {
  column: [],
  /**
   * 构建表单元素
   * @param {*} vm 当前vue实例
   * @returns 
   */
  buildColumn(vm) {
    if(!vm) {
      return this.column
    }
    this.column = [
      {
        label:'编号',
        prop:'id',
        search: false,
        searchType: '',
        searchSpan: 8,
        hide: true,
        span: 12,
        readonly: false,
        display: false,
        value: '',
        addDisabled: false,
        addDisplay: true,
        addDetail: false,
        editDisabled: false,
        editDisplay: true,
        editDetail: false,
        rules: [
          { required: false, message: '编号不能为空', trigger: "blur" }
        ]},
      {
        label:'参数名称',
        prop:'configName',
        search: true,
        searchType: 'EQ',
        searchSpan: 8,
        hide: false,
        span: 12,
        readonly: false,
        display: true,
        value: '',
        addDisabled: false,
        addDisplay: true,
        addDetail: false,
        editDisabled: false,
        editDisplay: true,
        editDetail: false,
        rules: [
          { required: true, message: '参数名称不能为空', trigger: "blur" }
        ]},
      {
        label:'参数键名',
        prop:'configKey',
        search: false,
        searchType: '',
        searchSpan: 8,
        hide: false,
        span: 12,
        readonly: false,
        display: true,
        value: '',
        addDisabled: false,
        addDisplay: true,
        addDetail: false,
        editDisabled: false,
        editDisplay: true,
        editDetail: false,
        rules: [
          { required: true, message: '参数键名不能为空', trigger: "blur" }
        ]},
      {
          label:'系统内置',
          prop:'isSystem',
          type: 'select',
          dicUrl: '/sys/dict/getByDictKey',
          dicMethod: 'post',
          search: false,
          searchType: '',
          searchSpan: 8,
          hide: false,
          span: 12,
          readonly: false,
          display: true,
          value: Number('2'),
          addDisabled: false,
          addDisplay: true,
          addDetail: false,
          editDisabled: false,
          editDisplay: true,
          editDetail: false,
          dicQuery: {
            dictKey: 'yes_no',
            type: 'enum'
          },
          dicFlag: true, // 表格打开表单的时候是否重新拉取字典
          props: {
            res: 'data.items',
            label: 'name',
            value: 'dictItemValue'
          },
          rules: [
            { required: true, message: '系统内置不能为空', trigger: "blur" }
          ]},
      {
          label:'参数键值',
          type: "textarea",
          prop:'configValue',
          search: false,
          hide: false,
          span: 12,
          readonly: false,
          display: true,
          value: '',
          addDisabled: false,
          addDisplay: true,
          addDetail: false,
          editDisabled: false,
          editDisplay: true,
          editDetail: false,
          rules: [
            { required: true, message: '参数键值不能为空', trigger: "blur" }
          ]},
      {
          label:'备注',
          type: "textarea",
          prop:'remark',
          search: false,
          hide: false,
          span: 12,
          readonly: false,
          display: true,
          value: '',
          addDisabled: false,
          addDisplay: true,
          addDetail: false,
          editDisabled: false,
          editDisplay: true,
          editDetail: false,
          rules: [
            { required: false, message: '备注不能为空', trigger: "blur" }
          ]},
    ]
    return this.column
  },
  /**
   * 动态构建搜索条件
   * @param {*} vm 当前vue实例
   * @returns 
   */
  buildSearchParam(vm) {
    let res = {}
    vm.option.column.forEach(item=>{
      if(item.search) {
        let key = `m_${item.searchType}_${item.prop}`
        let value = vm.search[item.prop]
        if(value!== undefined) {
          res[key] = value
        }
      }
    })
    return res;
  }
}